home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Resources.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  8.7 KB  |  257 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Resources.h
  3.  
  4.      Contains:    Resource Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __RESOURCES__
  21. #define __RESOURCES__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __MIXEDMODE__
  30. #include <MixedMode.h>
  31. #endif
  32.  
  33. #ifndef __FILES__
  34. #include <Files.h>
  35. #endif
  36. /*    #include <OSUtils.h>                                        */
  37. /*        #include <Memory.h>                                        */
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_ALIGN_SUPPORTED
  44. #pragma options align=mac68k
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT_SUPPORTED
  48. #pragma import on
  49. #endif
  50.  
  51.  
  52. enum {
  53.     resSysHeap                    = 64,                            /*System or application heap?*/
  54.     resPurgeable                = 32,                            /*Purgeable resource?*/
  55.     resLocked                    = 16,                            /*Load it in locked?*/
  56.     resProtected                = 8,                            /*Protected?*/
  57.     resPreload                    = 4,                            /*Load in on OpenResFile?*/
  58.     resChanged                    = 2,                            /*Resource changed?*/
  59.     mapReadOnly                    = 128,                            /*Resource file read-only*/
  60.     mapCompact                    = 64,                            /*Compact resource file*/
  61.     mapChanged                    = 32,                            /*Write map out at update*/
  62.     kResFileNotOpened            = -1,                            /*ref num return as error when opening a resource file*/
  63.     kSystemResFile                = 0                                /*this is the default ref num to the system file*/
  64. };
  65.  
  66. /*
  67.         ResErrProcPtr uses register based parameters on the 68k and cannot
  68.         be written in or called from a high-level language without the help of
  69.         mixed mode or assembly glue.
  70.  
  71.             typedef pascal void (*ResErrProcPtr)(OSErr thErr);
  72.  
  73.         In:
  74.          => thErr           D0.W
  75. */
  76.  
  77. #if GENERATINGCFM
  78. typedef UniversalProcPtr ResErrUPP;
  79. #else
  80. typedef Register68kProcPtr ResErrUPP;
  81. #endif
  82.  
  83. enum {
  84.     uppResErrProcInfo = kRegisterBased
  85.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterD0, SIZE_CODE(sizeof(OSErr)))
  86. };
  87.  
  88. #if GENERATINGCFM
  89. #define NewResErrProc(userRoutine)        \
  90.         (ResErrUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppResErrProcInfo, GetCurrentArchitecture())
  91. #else
  92. #define NewResErrProc(userRoutine)        \
  93.         ((ResErrUPP) (userRoutine))
  94. #endif
  95.  
  96. #if GENERATINGCFM
  97. #define CallResErrProc(userRoutine, thErr)        \
  98.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppResErrProcInfo, (thErr))
  99. #else
  100. /* (*ResErrProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  101. #endif
  102.  
  103. /*    These are no longer needed.
  104.  *    CFM provides us with the necessary run time initialization
  105.  *    entry points.
  106.  */
  107. extern pascal short InitResources(void)
  108.  ONEWORDINLINE(0xA995);
  109. extern pascal void RsrcZoneInit(void)
  110.  ONEWORDINLINE(0xA996);
  111. extern pascal void CloseResFile(short refNum)
  112.  ONEWORDINLINE(0xA99A);
  113. extern pascal short ResError(void)
  114.  ONEWORDINLINE(0xA9AF);
  115. extern pascal short CurResFile(void)
  116.  ONEWORDINLINE(0xA994);
  117. extern pascal short HomeResFile(Handle theResource)
  118.  ONEWORDINLINE(0xA9A4);
  119. extern pascal void CreateResFile(ConstStr255Param fileName)
  120.  ONEWORDINLINE(0xA9B1);
  121. extern pascal short OpenResFile(ConstStr255Param fileName)
  122.  ONEWORDINLINE(0xA997);
  123. extern pascal void UseResFile(short refNum)
  124.  ONEWORDINLINE(0xA998);
  125. extern pascal short CountTypes(void)
  126.  ONEWORDINLINE(0xA99E);
  127. extern pascal short Count1Types(void)
  128.  ONEWORDINLINE(0xA81C);
  129. extern pascal void GetIndType(ResType *theType, short index)
  130.  ONEWORDINLINE(0xA99F);
  131. extern pascal void Get1IndType(ResType *theType, short index)
  132.  ONEWORDINLINE(0xA80F);
  133. extern pascal void SetResLoad(Boolean load)
  134.  ONEWORDINLINE(0xA99B);
  135. extern pascal short CountResources(ResType theType)
  136.  ONEWORDINLINE(0xA99C);
  137. extern pascal short Count1Resources(ResType theType)
  138.  ONEWORDINLINE(0xA80D);
  139. extern pascal Handle GetIndResource(ResType theType, short index)
  140.  ONEWORDINLINE(0xA99D);
  141. extern pascal Handle Get1IndResource(ResType theType, short index)
  142.  ONEWORDINLINE(0xA80E);
  143. extern pascal Handle GetResource(ResType theType, short theID)
  144.  ONEWORDINLINE(0xA9A0);
  145. extern pascal Handle Get1Resource(ResType theType, short theID)
  146.  ONEWORDINLINE(0xA81F);
  147. extern pascal Handle GetNamedResource(ResType theType, ConstStr255Param name)
  148.  ONEWORDINLINE(0xA9A1);
  149. extern pascal Handle Get1NamedResource(ResType theType, ConstStr255Param name)
  150.  ONEWORDINLINE(0xA820);
  151. extern pascal void LoadResource(Handle theResource)
  152.  ONEWORDINLINE(0xA9A2);
  153. extern pascal void ReleaseResource(Handle theResource)
  154.  ONEWORDINLINE(0xA9A3);
  155. extern pascal void DetachResource(Handle theResource)
  156.  ONEWORDINLINE(0xA992);
  157. extern pascal short UniqueID(ResType theType)
  158.  ONEWORDINLINE(0xA9C1);
  159. extern pascal short Unique1ID(ResType theType)
  160.  ONEWORDINLINE(0xA810);
  161. extern pascal short GetResAttrs(Handle theResource)
  162.  ONEWORDINLINE(0xA9A6);
  163. extern pascal void GetResInfo(Handle theResource, short *theID, ResType *theType, Str255 name)
  164.  ONEWORDINLINE(0xA9A8);
  165. extern pascal void SetResInfo(Handle theResource, short theID, ConstStr255Param name)
  166.  ONEWORDINLINE(0xA9A9);
  167. extern pascal void AddResource(Handle theData, ResType theType, short theID, ConstStr255Param name)
  168.  ONEWORDINLINE(0xA9AB);
  169. extern pascal long GetResourceSizeOnDisk(Handle theResource)
  170.  ONEWORDINLINE(0xA9A5);
  171. extern pascal long GetMaxResourceSize(Handle theResource)
  172.  ONEWORDINLINE(0xA821);
  173. extern pascal long RsrcMapEntry(Handle theResource)
  174.  ONEWORDINLINE(0xA9C5);
  175. extern pascal void SetResAttrs(Handle theResource, short attrs)
  176.  ONEWORDINLINE(0xA9A7);
  177. extern pascal void ChangedResource(Handle theResource)
  178.  ONEWORDINLINE(0xA9AA);
  179. extern pascal void RemoveResource(Handle theResource)
  180.  ONEWORDINLINE(0xA9AD);
  181. extern pascal void UpdateResFile(short refNum)
  182.  ONEWORDINLINE(0xA999);
  183. extern pascal void WriteResource(Handle theResource)
  184.  ONEWORDINLINE(0xA9B0);
  185. extern pascal void SetResPurge(Boolean install)
  186.  ONEWORDINLINE(0xA993);
  187. extern pascal short GetResFileAttrs(short refNum)
  188.  ONEWORDINLINE(0xA9F6);
  189. extern pascal void SetResFileAttrs(short refNum, short attrs)
  190.  ONEWORDINLINE(0xA9F7);
  191. extern pascal short OpenRFPerm(ConstStr255Param fileName, short vRefNum, SInt8 permission)
  192.  ONEWORDINLINE(0xA9C4);
  193. extern pascal Handle RGetResource(ResType theType, short theID)
  194.  ONEWORDINLINE(0xA80C);
  195. #if SystemSevenOrLater
  196. extern pascal short HOpenResFile(short vRefNum, long dirID, ConstStr255Param fileName, SInt8 permission)
  197.  ONEWORDINLINE(0xA81A);
  198. #else
  199. extern pascal short HOpenResFile(short vRefNum, long dirID, ConstStr255Param fileName, SInt8 permission);
  200. #endif
  201. #if SystemSevenOrLater
  202. extern pascal void HCreateResFile(short vRefNum, long dirID, ConstStr255Param fileName)
  203.  ONEWORDINLINE(0xA81B);
  204. #else
  205. extern pascal void HCreateResFile(short vRefNum, long dirID, ConstStr255Param fileName);
  206. #endif
  207. extern pascal short FSpOpenResFile(const FSSpec *spec, SignedByte permission)
  208.  TWOWORDINLINE(0x700D, 0xAA52);
  209. extern pascal void FSpCreateResFile(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag)
  210.  TWOWORDINLINE(0x700E, 0xAA52);
  211. /*  partial resource calls  */
  212. extern pascal void ReadPartialResource(Handle theResource, long offset, void *buffer, long count)
  213.  TWOWORDINLINE(0x7001, 0xA822);
  214. extern pascal void WritePartialResource(Handle theResource, long offset, const void *buffer, long count)
  215.  TWOWORDINLINE(0x7002, 0xA822);
  216. extern pascal void SetResourceSize(Handle theResource, long newSize)
  217.  TWOWORDINLINE(0x7003, 0xA822);
  218. extern pascal Handle GetNextFOND(Handle fondHandle)
  219.  TWOWORDINLINE(0x700A, 0xA822);
  220. /* Use TempInsertROMMap to force the ROM resource map to be
  221.    inserted into the chain in front of the system. Note that
  222.    this call is only temporary - the modified resource chain
  223.    is only used for the next call to the resource manager.
  224.    See IM IV 19 for more information. */
  225. extern pascal void TempInsertROMMap(Boolean tempResLoad);
  226. #if CGLUESUPPORTED
  227. extern Handle getnamedresource(ResType theType, const char *name);
  228. extern Handle get1namedresource(ResType theType, const char *name);
  229. extern short openrfperm(const char *fileName, short vRefNum, char permission);
  230. extern short openresfile(const char *fileName);
  231. extern void createresfile(const char *fileName);
  232. extern void getresinfo(Handle theResource, short *theID, ResType *theType, char *name);
  233. extern void setresinfo(Handle theResource, short theID, const char *name);
  234. extern void addresource(Handle theResource, ResType theType, short theID, const char *name);
  235. #endif
  236. #if OLDROUTINENAMES
  237. #if CGLUESUPPORTED
  238. #define SizeResource(theResource) GetResourceSizeOnDisk(theResource)
  239. #define MaxSizeRsrc(theResource) GetMaxResourceSize(theResource)
  240. #define RmveResource(theResource) RemoveResource(theResource)
  241. #endif
  242. #endif
  243.  
  244. #if PRAGMA_IMPORT_SUPPORTED
  245. #pragma import off
  246. #endif
  247.  
  248. #if PRAGMA_ALIGN_SUPPORTED
  249. #pragma options align=reset
  250. #endif
  251.  
  252. #ifdef __cplusplus
  253. }
  254. #endif
  255.  
  256. #endif /* __RESOURCES__ */
  257.